import request from '@/utils/request'

// 统一前缀
var prefix = '/userService'

//查询所有权限
export function lookAllPermission() {
  return request({
    url: `${prefix}/per`,
    method: 'GET',
  })
}

// 条件查询权限
export function lookPermission(permission) {
  return request({
    url: `${prefix}/per/list`,
    method: 'GET',
    params: permission,
  })
}

// 添加一条权限
export function insertOnePermission(permission) {
  return request({
    url: `${prefix}/per`,
    method: 'POST',
    data: permission,
  })
}

// 修改权限
export function updateOnePermission(permission) {
  return request({
    url: `${prefix}/per`,
    method: 'PUT',
    data: permission,
  })
}

// 删除权限
export function deletePermission(ids) {
  return request({
    url: `${prefix}/per`,
    method: 'DELETE',
    data: ids,
  })
}

// 根据路由ID查询对应权限列表
export function lookPermissionByRouter(routerId) {
  return request({
    url: `${prefix}/per/router`,
    method: 'GET',
    params: {id: routerId},
  })
}

// 根据路由ID查询对应权限列表
export function lookPermissionByRole(role) {
  return request({
    url: `${prefix}/per/role`,
    method: 'GET',
    params: role,
  })
}

// 绑定路由到权限
export function bindRouter(map) {
  return request({
    url: `${prefix}/per/bind`,
    method: 'POST',
    data: map,
  })
}

// 解绑路由到权限
export function unbindRouter(map) {
  return request({
    url: `${prefix}/per/unbind`,
    method: 'DELETE',
    data: map,
  })
}
